package com.ljf.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ljf.admin.POJO.SysDept;
import com.ljf.admin.POJO.SysUserDept;
import com.ljf.admin.mapper.SysDeptMapper;
import com.ljf.admin.mapper.SysUserDeptMapper;
import com.ljf.admin.service.SysDeptService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @Auther: lijinfeng
 * @Date: 2022/4/21
 * @Description 描述:
 */
@Service
public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> implements SysDeptService {

    @Resource
    private SysDeptMapper sysDeptMapper;

    @Resource
    private SysUserDeptMapper sysUserDeptMapper;

    @Override
    public int updateBatch(List<SysDept> list) {
        return baseMapper.updateBatch(list);
    }
    @Override
    public int updateBatchSelective(List<SysDept> list) {
        return baseMapper.updateBatchSelective(list);
    }
    @Override
    public int batchInsert(List<SysDept> list) {
        return baseMapper.batchInsert(list);
    }

    @Override
    @Transactional
    public void deleteDept(Long deptId) {
        removeById(deptId);
        QueryWrapper<SysUserDept> qw = new QueryWrapper();
        qw.eq("dept_id",deptId);
        sysUserDeptMapper.delete(qw);
    }

    @Override
    public List<Map<String, String>> getDeptUser() {
        return sysDeptMapper.getDeptUser();
    }


}
